package com.fay.designPattern.principles.solid;
/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/3/1 17:37
 * @Version 1.0
 */
public class TpsAlertHandler extends OcpAlertHandler{

    public TpsAlertHandler(AlertRule rule, Notification notification) {
        super(rule, notification);
    }

    @Override
    public void check(ApiStatInfo apiStatInfo) {
        long tps = apiStatInfo.getRequestCount() / apiStatInfo.getDurationOfSeconds();
        if (tps > rule.getMatchedRule(apiStatInfo.getApi()).getMaxTps()) {
            notification.notify(NotificationEmergencyLevel.URGENCY, "...");
        }
    }
}
